<template>
  <div class="sampleCount">
    <el-form ref="form" :model="form" label-width="80px">
      <el-row>
        <el-col :span="11"
          ><el-form-item label="样本数">
            <el-input-number
              v-model="form.count"
              :min="1"
              :max="sampleParams.sampleTotal"
            ></el-input-number> </el-form-item
        ></el-col>
        <el-col :span="11">
          <el-form-item label="样本总数">
            <div>{{ sampleParams.sampleTotal }}</div>
          </el-form-item></el-col
        >
      </el-row>
      <el-row style="text-align: right">
        <el-button size="small" @click="cancelDialog">取 消</el-button>
        <el-button type="primary" size="small" @click="goToreport"
          >确 定</el-button
        >
      </el-row>
    </el-form>
  </div>
</template>

<script>
import { mapState, mapGetters } from "vuex";
export default {
  props: ["sampleParams"],
  data() {
    return {
      total: "",
      count: "",
      form: { count: "" },
      userInfo: {},
    };
  },
  created() {
    this.userInfo = JSON.parse(localStorage.getItem("saber-userInfo")).content;
  },
  computed: {
    ...mapState(["enterprise"]),
    ...mapGetters(["userInfo"]),
    isEnterprise() {
      const type = this.userInfo.schoolType;
      return type == 8 || type == 9;
    },
  },
  methods: {
    goToreport() {
      let path = this.isEnterprise
        ? "/groupReport/enterprise"
        : "/groupReport/groupAnalysis2";
      if (
        this.sampleParams.gaugeId ==
        "314777_1633069375781_f52ede3a08f140f680f040b2df8adba7"
      ) {
        path = "/groupReport/groupAnalysis";
      }
      // debugger;
      this.$router.push({
        path: path,
        query: {
          id: this.sampleParams.projectId,
          gaugeId: this.sampleParams.gaugeId,
          sampleCount: this.form.count,
          sampleTotal: this.sampleParams.sampleTotal,
        },
      });
    },
    cancelDialog() {
      this.$emit("close");
    },
  },
};
</script>

<style lang="scss" scoped>
.sampleCount {
}
</style>
